<!DOCTYPE html>
<head>
<meta charset="utf-8">
<!-- Viewport Metatag -->
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- Required Stylesheets -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/bootstrap/css/bootstrap.min.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/mws-style.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/mws-theme.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/fonts/icomoon/style.css" media="screen">
<!-- Core JavaScript -->
<script src="__PUBLIC__/Admin/js/libs/jquery-1.8.3.js"></script>
<block name="title">
<title>管理员添加</title>
</block>
<style type="text/css">
    #mws-container{margin-left:0px;}
    select{
        width: 88px;
        color: black;
        font-weight:bold;
        font-size:inherit;
    }
    select option{
        font-weight: bold;
        font-family: "Times New Roman";
    }
    .confirmpwd_error_tip,.pwd_error_tip,.name_error_tip,.region_error_tip{
        color: red;
        font-weight: bold;
    }
</style>
</head>

<body>

    <!-- Start Main Wrapper -->
    <div id="mws-wrapper">

        <!-- Main Container Start -->
        <div id="mws-container" class="clearfix">
        	<!-- Inner Container Start -->
            <div class="container">
                <block name="con">
            	<div class="mws-panel grid_8">
                	<div class="mws-panel-header">
                        <span><i class="icon-plus"></i> 管理员添加</span>
                    </div>
                    <div class="mws-panel-body no-padding">
                    	<form class="mws-form" action="{:U('Admin/Admin/insert')}" method="post" id="user">
                    		<div class="mws-form-inline">
                    			<div class="mws-form-row">
                    				<label class="mws-form-label">管理员名</label>
                    				<div class="mws-form-item">
                    					<input type="text" class="small" id="Username" name="Username">
                                        <span class="name_error_tip"></span>
                    				</div>
                    			</div>
                    			<div class="mws-form-row">
                                    <label class="mws-form-label">管理员密码</label>
                                    <div class="mws-form-item">
                                        <input type="password" onpaste="return false" oncopy="return false" class="small" name="Password">
                                        <span class="pwd_error_tip"></span>
                                    </div>
                                </div>
                                <div class="mws-form-row">
                                    <label class="mws-form-label">确认密码</label>
                                    <div class="mws-form-item">
                                        <input type="password" onpaste="return false" oncopy="return false" class="small" name="ConfirmPassword">
                                        <span class="confirmpwd_error_tip"></span>
                                    </div>
                                </div>

                                <div class="mws-form-row">
                                    <label class="mws-form-label">管理员区域</label>
                                    <div class="mws-form-item">
                                        <select name="city" id="city">
                                            <option>请选择</option>
                                            <option>南京市</option>
                                            <option>无锡市</option>
                                            <option>徐州市</option>
                                            <option>常州市</option>
                                            <option>苏州市</option>
                                            <option>南通市</option>
                                            <option>连云港市</option>
                                            <option>盐城市</option>
                                            <option>扬州市</option>
                                            <option>镇江市</option>
                                            <option>泰州市</option>
                                            <option>宿迁市</option>
                                        </select>
                                        <select name="county" id="county">
                                            <option>请选择</option>
                                        </select>
                                        <span class="region_error_tip"></span>
                                    </div>
                                </div>
                    		</div>
                    		<div class="mws-button-row">
                    			<input type="submit" value="添加" class="btn btn-danger">
                    			<input type="reset" value="重置" class="btn ">
                                <input type="button" value="返回"  class="btn btn-warning" onclick="javascrtpt:window.location.href='index.html'">
                    		</div>
                    	</form>
                    </div>    	
                </div>
                </block>
        </div>
            </div>
        <script type="text/javascript">
            var regionOk = false;
            var pwdOk =false;
            var repwdOk = false;
            var nameOk = false;
            var m = $('.region_error_tip');
            $("#city").change(function(){
                $("#county").html('<option selected="selected">请选择</option>')
                var current_city = $("select[id='city'] option:selected").html();
                var current_county = $("select[id='county'] option:selected").html();
                if(current_city=="南京市"){
                    $("#county").append('<option>全市</option><option>玄武区</option><option>秦淮区</option><option>建邺区</option><option>鼓楼区</option>' +
                            '<option>浦口区</option><option>栖霞区</option><option>雨花台区</option><option>江宁区</option><option>六合区</option>' +
                            '<option>溧水区</option><option>高淳区</option>')
                }
                if(current_city=="无锡市"){
                    $("#county").append('<option>全市</option><option>锡山区</option><option>惠山区</option><option>滨湖区</option><option>梁溪区</option>' +
                            '<option>新吴区</option><option>江阴市</option><option>宜兴市</option>')
                }
                if(current_city=="徐州市"){
                    $("#county").append('<option>全市</option><option>鼓楼区</option><option>云龙区</option><option>贾汪区</option><option>泉山区</option>' +
                            '<option>铜山区</option><option>丰县</option><option>沛县</option><option>睢宁县</option><option>新沂市</option>' +
                            '<option>邳州市</option>')
                }
                if(current_city=="常州市"){
                    $("#county").append('<option>全市</option><option>天宁区</option><option>钟楼区</option><option>新北区</option><option>武进区</option>' +
                            '<option>金坛区</option><option>溧阳市</option>')
                }
                if(current_city=="苏州市"){
                    $("#county").append('<option>全市</option><option>虎丘区</option><option>吴中区</option><option>相城区</option><option>姑苏区</option>' +
                            '<option>吴江区</option><option>常熟市</option><option>张家港市</option><option>昆山市</option><option>太仓市</option>')
                }
                if(current_city=="南通市"){
                    $("#county").append('<option>全市</option><option>崇川区</option><option>港闸区</option><option>通州区</option><option>海安县</option>' +
                            '<option>如东县</option><option>启东市</option><option>如皋市</option><option>海门市</option>')
                }
                if(current_city=="连云港市"){
                    $("#county").append('<option>全市</option><option>崇川区</option><option>海州区</option><option>赣榆区</option><option>东海县</option>' +
                            '<option>灌云县</option><option>灌南县</option>')
                }
                if(current_city=="淮安市"){
                    $("#county").append('<option>全市</option><option>淮安区</option><option>淮阴区</option><option>清江浦区</option><option>洪泽区</option>' +
                            '<option>涟水县</option><option>盱眙县</option><option>金湖县</option>')
                }
                if(current_city=="盐城市"){
                    $("#county").append('<option>全市</option><option>亭湖区</option><option>盐都区</option><option>大丰区</option><option>响水县</option>' +
                            '<option>滨海县</option><option>阜宁县</option><option>射阳县</option><option>建湖县</option><option>东台市</option>')
                }
                if(current_city=="扬州市"){
                    $("#county").append('<option>全市</option><option>广陵区</option><option>邗江区</option><option>江都区</option><option>宝应县</option>' +
                            '<option>仪征市</option><option>高邮市</option>')
                }
                if(current_city=="镇江市"){
                    $("#county").append('<option>全市</option><option>京口区</option><option>润州区</option><option>丹徒区</option><option>丹阳市</option>' +
                            '<option>扬中市</option><option>句容市</option>')
                }
                if(current_city=="泰州市"){
                    $("#county").append('<option>全市</option><option>海陵区</option><option>高港区</option><option>姜堰区</option><option>兴化市</option>' +
                            '<option>靖江市</option><option>泰兴市</option>')
                }
                if(current_city=="宿迁市"){
                    $("#county").append('<option>全市</option><option>宿城区</option><option>宿豫区</option><option>沭阳县</option><option>泗阳县</option>' +
                            '<option>泗洪县</option>')
                }
                if(current_city=='请选择'){
                    m.css('display','block').html('请选择市');
                    regionOk = false;
                }
                else if(current_county=='请选择'){
                    m.css('display','block').html('请选择区县');
                    regionOk = false;
                }
                else{
                    m.css('display','none');
                    regionOk = true;
                }
               // $("#Username").val($("select[id='city'] option:selected").val()+$("select[id='county'] option:selected").val());
            })
            $("#county").change(function(){
                var current_county = $("select[id='county'] option:selected").html();
                if(current_county=='请选择'){
                    m.css('display','block').html('请选择区县');
                    regionOk = false;
                }
                else{
                    m.css('display','none');
                    regionOk = true;
                }
            })
            $('input[name=Username]').blur(function(){
                var v = $(this).val();
                var m = $('.name_error_tip');
                if(v == ''){
                    m.css('display','block').html('请输入用户名');
                    nameOk = false;
                }
                else{
                    var myReg = /^[a-zA-Z0-9_]{0,}$/;
                    if (!myReg.test($(this).val())) {
                        m.css('display','block').html('用户名不能包含中文和特殊字符');
                        nameOk = false;
                    }
                    else {
                        m.css('display','none');
                        nameOk = true;
                    }
                }
            })
            $('input[name=Password]').blur(function(){
                var v = $(this).val();
                var m = $('.pwd_error_tip');
                if(v == ''){
                    m.css('display','block').html('请输入密码');
                    pwdOk = false;
                }
                else{
                    m.css('display','none');
                    pwdOk = true;
                }
            })
            $('input[name=ConfirmPassword]').blur(function(){
                var v = $(this).val();
                var pw = $('input[name=Password]').val();
                var m = $('.confirmpwd_error_tip');
                if(v == ''){
                    m.css('display','block').html('请输入确认密码');
                    repwdOk = false;
                }
                else if(v != pw){
                    m.css('display','block').html('确认密码必须和密码一致');
                    repwdOk = false;
                }
                else{
                    m.css('display','none');
                    repwdOk = true;
                }
            })
            $('#user').submit(function(){
                $('input[name=Username]').trigger('blur');
                $('input[name=Password]').trigger('blur');
                $('input[name=ConfirmPassword]').trigger('blur');
                var m = $('.region_error_tip');
                var current_city = $("select[id='city'] option:selected").html();
                var current_county = $("select[id='county'] option:selected").html();
                if(current_city=='请选择'){
                    m.css('display','block').html('请选择市');
                    regionOk = false;
                }
                else if(current_county=='请选择'){
                    m.css('display','block').html('请选择区县');
                    regionOk = false;
                }
                else{
                    m.css('display','none');
                    regionOk = true;
                }
                if(nameOk && pwdOk && regionOk && repwdOk){
                    return true;
                }
                else{
                    return false;
                }
            })
        </script>
        <!-- Main Container End -->
        
    </div>

</body>
</html>
